﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Windows.Data;

using System.Windows.Controls;

using System.Windows;

namespace HA.ModFlow.Controls
{
    //这里的一切都是基于list<double> 结构的


    /// <summary>
    /// 用于表示多应力期部分是否显示
    /// </summary>
    public class MultiSPVisibilityConvertor : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            List<double> b = (List<double>)value;
            if (b.Count>1)
            {

                return Visibility.Visible;

            }

            else
            {
                return Visibility.Collapsed;
            }

        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

    }


    public class NotMultiSPVisibilityConvertor : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            List<double> b = (List<double>)value;
            if (b.Count > 1)
            {

                return Visibility.Collapsed;

            }

            else
            {
                return Visibility.Visible;
            }

        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

    }




    public class MultiSPEnabledConvertor : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {



            string str =(string) value;

            if (str == "Transient")
            {
                return true;

            }

            else
            {
                return false;
            }

        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();

        }

    }


    public class MultiSPSelectedConvertor : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {



            List<double> b = (List<double>)value;

            double val=b[0];

         

           if (b.Equals(val))
            {

                return "Transient";

            }

            else
            {
                return "Constant";
            }

           

        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();

        }

    }



    public class MultiSPSingleConvertor : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {


            List<double> b = (List<double>)value;

            bool allEqual=true;

            double val = b[0];

            foreach (double item in b)
            {
                if (val!=item)
                {

                    allEqual = false;

                    break;
                    
                }
                
            }

          



            if (allEqual)
            {

                return true;

            }

            else
            {
                return false;
            }

       



        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();

        }

    }


    
}
